package com.huawei.statistics.controller.common;

import com.huawei.statistics.annotation.WebCrossOrigin;
import com.huawei.statistics.common.Constant;
import com.huawei.statistics.platform.monitor.ClientManager;
import com.huawei.statistics.platform.monitor.OnlineAdminManager;
import com.huawei.statistics.platform.monitor.OnlineWXMember;
import com.huawei.statistics.service.common.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * Created by 许湛司 on 2017/4/20.
 * webCrossOrigin 跨域调用
 */
@WebCrossOrigin
public class AbstractController{
    public final static String DATA = "data";
    public static final String PUBLIC_SIGNAL_PARAM="appid";

    @Autowired
    @Qualifier("baseServiceImpl")
    public BaseService baseService;

    @Autowired
    public ClientManager clientManager;

    /**
     * 获取当前在线的管理用户
     * @return
     */
    public OnlineAdminManager getOnlineAdminUser(){
        if (Constant.TEST){
            OnlineAdminManager wxMember=new OnlineAdminManager();
            wxMember.setId(Long.valueOf(1));
            wxMember.setHead("http://wx.qlogo.cn/mmhead/Q3auHgzwzM5POJPvlyib6vv7fuLBRVbMC4T45Lp5yIpwaS5eyscZAqQ/0");
            wxMember.setNick("许湛司");
            wxMember.setUsername("123456");
            wxMember.setRealName("许湛司");
            return wxMember;
        }
        return clientManager.getCurrentUser(OnlineAdminManager.class);
    }

    /**
     * 获取当前在线用户
     * @return
     */
    public OnlineWXMember getOnlineUser(){
        if (Constant.TEST){
            OnlineWXMember wxMember=new OnlineWXMember();
            wxMember.setCode("10000003");
            wxMember.setId(Long.valueOf(1));
            wxMember.setHead("http://wx.qlogo.cn/mmhead/Q3auHgzwzM5POJPvlyib6vv7fuLBRVbMC4T45Lp5yIpwaS5eyscZAqQ/0");
            wxMember.setNickName("许湛司");
            wxMember.setOpenId("onjkXv5y5rJc-AGfRjriHEm4Et9U");
            return wxMember;
        }
        return clientManager.getCurrentUser(OnlineWXMember.class);
    }


}
